<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
    <title>我的收藏</title>
    <link rel="icon" href="/assets/img/favicon.ico">

    <link rel="stylesheet" type="text/css" href="css/webbase.css" />
    <link rel="stylesheet" type="text/css" href="css/pages-seckillOrder.css" />
    <script src="./js/vue/vue.js"></script>
    <script src="./js/axios.min.js"></script>
    <script src="./js/common.js"></script>
</head>

<body>
<!--页面顶部白条条，由js动态加载-->
<script type="text/javascript" src="plugins/jquery/jquery.min.js"></script>
<div class="nav-bottom"></div>
<script type="text/javascript">$(".nav-bottom").load("top.html");</script>

<script type="text/javascript" src="js/plugins/jquery/jquery.min.js"></script>
<script type="text/javascript">
    $(function () {
        $("#service").hover(function () {
            $(".service").show();
        }, function () {
            $(".service").hide();
        });
        $("#shopcar").hover(function () {
            $("#shopcarlist").show();
        }, function () {
            $("#shopcarlist").hide();
        });

    })
</script>
<script type="text/javascript" src="js/plugins/jquery.easing/jquery.easing.min.js"></script>
<script type="text/javascript" src="js/plugins/sui/sui.min.js"></script>
<script type="text/javascript" src="js/plugins/jquery-placeholder/jquery.placeholder.min.js"></script>
<script type="text/javascript" src="js/widget/nav.js"></script>
</body>
<!--header-->
<div id="account">
    <div class="py-container">
        <div class="yui3-g collect">
            <!--左侧列表-->
            <div class="yui3-u-1-6 list">

                    <div class="person-info">
                        <div class="person-photo"><img src="img/_/photo.png" alt=""></div>
                        <div class="person-account">
                            <span class="name">Michelle</span>
                            <span class="safe">账户安全</span>
                        </div>
                        <div class="clearfix"></div>
                    </div>
                    <div class="list-items">
                        <dl>
							<dt><i>·</i> 订单中心</dt>
							<dd ><a href="home-index.html"   >我的订单</a></dd>
							<dd><a href="home-order-pay.html" >待付款</a></dd>
							<dd><a href="home-order-send.html"  >待发货</a></dd>
							<dd><a href="home-order-receive.html" >待收货</a></dd>
							<dd><a href="home-order-evaluate.html" >待评价</a></dd>
						</dl>
						<dl>
							<dt><i>·</i> 我的中心</dt>
							<dd><a href="home-person-collect.html" class="list-active">我的收藏</a></dd>
							<dd><a href="home-person-footmark.html">我的足迹</a></dd>
						</dl>
						<dl>
							<dt><i>·</i> 物流消息</dt>
						</dl>
						<dl>
							<dt><i>·</i> 设置</dt>
							<dd><a href="home-setting-info.html">个人信息</a></dd>
							<dd><a href="home-setting-address.html"  >地址管理</a></dd>
							<dd><a href="home-setting-safe.html" >安全管理</a></dd>
						</dl>
                    </div>
                </div>
                <!--右侧主内容-->
                <div class="yui3-u-5-6 goods" >
                    <div class="body">
                            <h4>收藏的商品</h4>
                            <div v-if="collects!=null" class="goods-list" id="collectApp">
                                <ul class="yui3-g"  id="goods-list">
                                    <li class="yui3-u-1-4" v-for="(collect,index) in collects" :key="index">
                                        <div class="list-wrap">
                                            <a :href="'/item/'+ collect.spuId +'.html'" target="_blank"><div class="p-img"><img :src="collect.image" alt=''></div></a>
                                            <div>
                                                <div v-if="collect.currentPrice==null" class="price"><br><strong><em>¥</em> <i>{{ly.formatPrice(collect.price)}}</i></strong></div>
                                                <div v-else-if="collect.currentPrice<collect.price" class="price"><span style="font-size: 0.1px" >比加入是降价<em>{{ly.formatPrice(collect.price-collect.currentPrice)}}</em>元<br></span><strong><em>¥</em> <i>{{ly.formatPrice(collect.currentPrice)}}</i></strong></div>
                                                <div v-else class="price"><br><strong><em>¥</em> <i>{{ly.formatPrice(collect.currentPrice)}}</i></strong></div>
                                            </div>
                                            <div class="attr" style="flow: hidden;text-overflow: ellipsis"><em>{{collect.title}}</em></div>
                                            <div class="cu" style="overflow: hidden;text-overflow: ellipsis"><span>促</span><em v-html="collect.subTitle"></em></div>
                                            <div class="operate">
                                                <a href="javascript:void(0);"  class="sui-btn btn-bordered btn-danger" @click="addCart(collect)">加入购物车</a>
                                                <a href="javascript:void(0);" class="sui-btn btn-bordered">对比</a>
                                                <a href="javascript:void(0);" class="sui-btn btn-bordered" @click="cl">降价通知</a>
                                            </div>
                                        </div>
                                    </li >
                                </ul>
                            </div>
                      
                        
                        <!--猜你喜欢-->
                        <div class="like-title">
                            <div class="mt">
                                <span class="fl"><strong>猜你喜欢</strong></span>
                            </div>
                        </div>
                        <div class="like-list">
                            <ul class="yui3-g">
                                <li class="yui3-u-1-4">
                                    <div class="list-wrap">
                                        <div class="p-img">
                                            <img src="img/_/itemlike01.png" />
                                        </div>
                                        <div class="attr">
                                            <em>DELL戴尔Ins 15MR-7528SS 15英寸 银色 笔记本</em>
                                        </div>
                                        <div class="price">
                                            <strong>
											<em>¥</em>
											<i>3699.00</i>
										</strong>
                                        </div>
                                        <div class="commit">
                                            <i class="command">已有6人评价</i>
                                        </div>
                                    </div>
                                </li>
                                <li class="yui3-u-1-4">
                                    <div class="list-wrap">
                                        <div class="p-img">
                                            <img src="img/_/itemlike02.png" />
                                        </div>
                                        <div class="attr">
                                            <em>Apple苹果iPhone 6s/6s Plus 16G 64G 128G</em>
                                        </div>
                                        <div class="price">
                                            <strong>
											<em>¥</em>
											<i>4388.00</i>
										</strong>
                                        </div>
                                        <div class="commit">
                                            <i class="command">已有700人评价</i>
                                        </div>
                                    </div>
                                </li>
                                <li class="yui3-u-1-4">
                                    <div class="list-wrap">
                                        <div class="p-img">
                                            <img src="img/_/itemlike03.png" />
                                        </div>
                                        <div class="attr">
                                            <em>DELL戴尔Ins 15MR-7528SS 15英寸 银色 笔记本</em>
                                        </div>
                                        <div class="price">
                                            <strong>
											<em>¥</em>
											<i>4088.00</i>
										</strong>
                                        </div>
                                        <div class="commit">
                                            <i class="command">已有700人评价</i>
                                        </div>
                                    </div>
                                </li>
                                <li class="yui3-u-1-4">
                                    <div class="list-wrap">
                                        <div class="p-img">
                                            <img src="img/_/itemlike04.png" />
                                        </div>
                                        <div class="attr">
                                            <em>DELL戴尔Ins 15MR-7528SS 15英寸 银色 笔记本</em>
                                        </div>
                                        <div class="price">
                                            <strong>
											<em>¥</em>
											<i>4088.00</i>
										</strong>
                                        </div>
                                        <div class="commit">
                                            <i class="command">已有700人评价</i>
                                        </div>
                                    </div>
                                </li>

                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="./js/vue/vue.js"></script>
<script src="./js/axios.min.js"></script>
<script src="./js/common.js"></script>
<script type="text/javascript">

    var vm = new Vue({
        el: "#account",
        data: {
            ly,
            collects:[],//收藏列表
            userA: {},
        },
        created() {
            //左侧获取用户信息
            ly.http.get('/user/user').then(resp => {
                this.userA = resp.data;
            }).catch(e => {
                console.log("查询左侧列表用户信息失败");
                window.location = "login.html";
            });

            this.loadCollects();
        },

        methods: {
            //加载收藏商品
            loadCollects(){
                ly.http.get('/auth/verify').then(resp=>{
                    //已登录
                    ly.http.get('/collect/findAllCollects'
                    ).then(resp=>{
                        this.collects = resp.data;
                    }).catch(e=>{
                        console.log('加载收藏商品失败');
                    })

                }).catch(e=>{
                    alert("请先登录")
                });

            },

            //添加购物车
            addCart(collect){
                //判断当前用户是否登录
                ly.http.get('/auth/verify').then(resp => {
                    //已经登录
                    ly.http.post('/cart', {
                        "skuId": collect.skuId,
                        "title": collect.title,
                        "image": collect.image,
                        "price": collect.price,
                        "num": 1,
                        "ownSpec": collect.ownSpec
                    }).then(resp => {
                        //跳转到购物车列表页面
                        alert("添加购物车成功")
                    }).catch(e => {
                        console.log('添加购物车失败');
                    });

                }).catch(e => {

                    //未登录
                    //判断当前商品是否已经存在于购物车列表中
                    //1.取出当前购物车列表
                    let carts = ly.store.get('LY_CART') || [];

                    //2.判断skuId是否相等
                    let cart = carts.find(cart => cart.skuId == this.selectedSku.id);

                    if (cart) {
                        //如果存在，则数量增加
                        cart.num += 1;
                    } else {
                        //如果不存在，则把当前商品数据添加到购物车列表
                        carts.push({
                            "skuId": collect.skuId,
                            "title": collect.title,
                            "image": collect.image,
                            "price": collect.price,
                            "num": 1,
                            "ownSpec": collect.ownSpec
                        });
                    }

                    //把更新后carts数据设置到localStorage
                    ly.store.set('LY_CART', carts);

                    //3.跳转到购物车列表页面
                    window.location.href = "http://www.leyou.com/cart.html";
                });
            }

        },

    });


</script>


	<!-- 底部栏位 -->
	<!--页面底部，由js动态加载-->
	<div class="clearfix footer"></div>
	<script type="text/javascript">$(".footer").load("foot.html");</script>
	<!--页面底部END-->

</html>